function animate(obj, json, interval, sp, fn) {
    clearInterval(obj.timer);//取消之前的操作
    // var k = 0;
    // var j = 0;

    //得到当前的css样式
    function getStyle(obj, arr) {
    	if(obj.currentStyle){
            return obj.currentStyle[arr];    //针对ie
        } else {
        	return document.defaultView.getComputedStyle(obj, null)[arr]; 
        }
    }
    //动画开始
    obj.timer = setInterval(function(){
        //j ++;
        var flag = true;
        for(var arr in json) {
        	var icur = 0;
            //k++;
            if(arr == "opacity") {//特殊属性
            	icur = Math.round(parseFloat(getStyle(obj, arr))*100);
            } else {
            		//某一个属性值随时变化
            		icur = parseInt(getStyle(obj, arr));
            		console.log(icur);
            	}
            	var speed = (json[arr] - icur) * sp;
            	speed = speed > 0 ? Math.ceil(speed): Math.floor(speed);
            	if(icur != json[arr]){
            		flag = false;
            	} 
            	if(arr == "opacity"){
            		obj.style.filter = "alpha(opacity : '+(icur + speed)+' )";
            		obj.style.opacity = (icur + speed)/100;
            	}else {
            		obj.style[arr] = icur + speed + "px";
            	}
            //console.log(j + "," + arr +":"+ flag);
        }

        //回调函数
        if(flag){
        	clearInterval(obj.timer);
            // console.log(j + ":" + flag);  
            // console.log("k = " + k);
            // console.log("j = " + j);
            // console.log("DONE");
            if(fn){
            	fn();
            }
        }
    },interval);
    
}
